package com.brillilab.service.core.method.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.brillilab.dao.mapper.method.MethodRelateReagentMapper;
import com.brillilab.domain.po.method.MethodRelateReagent;
import com.brillilab.domain.vo.method.MethodRelateReagentVo;
import com.brillilab.service.core.method.IMethodRelateReagentService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wuzhiyu
 * @Title: MethodRelateRagentServiceImpl
 * @ProjectName brill_lab
 * @Description: TODO
 * @date 2019/4/2614:09
 */
@Service
@Transactional
public class MethodRelateRagentServiceImpl implements IMethodRelateReagentService {

    @Resource
    private MethodRelateReagentMapper methodRelateReagentMapper;

    @Override
    public List<MethodRelateReagent> listMethodRelateReagentByMethodId(Long methodId) {
        LambdaQueryWrapper<MethodRelateReagent> query = new LambdaQueryWrapper<>();
        query.eq(MethodRelateReagent::getMethodId, methodId);
        return methodRelateReagentMapper.selectList(query);
    }

    @Override
    public boolean saveRelateReagentList(List<MethodRelateReagent> relateReagentList) {
        if(!CollectionUtils.isEmpty(relateReagentList)){
            return methodRelateReagentMapper.saveRelateReagentList(relateReagentList)>0;
        }
        return false;
    }

    @Override
    public List<MethodRelateReagent> listByStepId(Long stepId) {
        return methodRelateReagentMapper.selectList(
                new LambdaQueryWrapper<MethodRelateReagent>()
                        .eq(MethodRelateReagent::getStepId,stepId));
    }

    @Override
    public List<MethodRelateReagentVo> selectVoList(Long stepId) {
        return methodRelateReagentMapper.selectVoList(stepId);
    }
}
